import os
import platform

def joinPath(root, subdir):
  return os.path.normpath(os.path.join(root, subdir))

OS_NAME = platform.system()

PRO_ROOT = os.path.normpath(os.getcwd())
TRD_DIR = joinPath(PRO_ROOT, '3rd')
BUILD_DIR = joinPath(PRO_ROOT, 'build')
OBJS_DIR = joinPath(BUILD_DIR, 'objs')
LIBS_DIR = joinPath(BUILD_DIR, 'libs')
BIN_DIR = joinPath(BUILD_DIR, 'bin')

OS_LINKFLAGS = ''
LINKFLAGS = OS_LINKFLAGS;

OS_LIBPATH = []
LIBPATH = [LIBS_DIR] + OS_LIBPATH

OS_FLAGS = ''
if ARGUMENTS.get('debug', 0):
  OS_FLAGS = '-g'

COMMON_CCFLAGS = ''
CCFLAGS = OS_FLAGS + COMMON_CCFLAGS 

LIBS=['cairo', 'pixman', 'freetype', 'png', 'm', 'dl']

OS_CPPPATH = ['/usr/local/include/freetype2']

CPPPATH = [joinPath(TRD_DIR, 'pixman'), joinPath(TRD_DIR, 'cairo')] + OS_CPPPATH

os.environ['LIBS_DIR'] = LIBS_DIR;
os.environ['BIN_DIR'] = BIN_DIR;

DefaultEnvironment(
  CCFLAGS = CCFLAGS, 
  LIBS = LIBS,
  LIBPATH = LIBPATH,
  CPPPATH = CPPPATH,
  LINKFLAGS = LINKFLAGS
)

SConscript(joinPath(TRD_DIR, 'pixman/SConscript'), variant_dir=joinPath(OBJS_DIR, 'pixman'), duplicate=0)
SConscript(joinPath(TRD_DIR, 'cairo/SConscript'), variant_dir=joinPath(OBJS_DIR, 'cairo'), duplicate=0)
SConscript('src/SConscript', variant_dir=OBJS_DIR, duplicate=0)
